/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package launchPoints;

import decisionTree.articleTextToWordVector;
import java.io.IOException;

/**
 *
 * @author hubert
 */
public class createZscoreWordVectorsForArticles {

    static java.io.File isCancerArticles = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/input/isCancer/isCancer");
    static java.io.File restArticles = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/input/rest");
    static java.io.File isCancerVectors = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/wordVectors/isCancer");
    static java.io.File restVectors = new java.io.File("/home/hubert/hadoopStuff/sampleCodeRun/wordVectors/rest");

    public void go() {
        if (this.isCancerArticles.exists() && this.restArticles.exists()) {
            try {
                if (!this.isCancerVectors.exists()) {
                    this.isCancerVectors.mkdirs();
                }
                if (!this.restVectors.exists()) {
                    this.restVectors.mkdirs();
                }
                decisionTree.top100List zScores = new decisionTree.top100ListZScore();
                for(java.io.File article : this.isCancerArticles.listFiles()){
                    //System.out.println(this.isCancerVectors.getAbsolutePath() + "/" + article.getName());
                    decisionTree.top100List wrdVector= decisionTree.articleTextToWordVector.convertText(article, zScores);
                    wrdVector = wrdVector.entryByEntyWeightMult(zScores);
                    wrdVector.saveToFile(new java.io.File(""+this.isCancerVectors.getAbsolutePath() + "/" + article.getName()));
                }
                for(java.io.File article : this.restArticles.listFiles()){
                    //System.out.println(this.isCancerVectors.getAbsolutePath() + "/" + article.getName());
                    decisionTree.top100List wrdVector= decisionTree.articleTextToWordVector.convertText(article, zScores);
                    wrdVector = wrdVector.entryByEntyWeightMult(zScores);
                    wrdVector.saveToFile(new java.io.File(""+this.restVectors.getAbsolutePath() + "/" + article.getName()));
                }
            } catch (java.lang.Exception e) {
                e.printStackTrace();
            }

        } else {
            System.out.println("unable to locate source files");
        }
    }

    public static void main(String[] args) {
        createZscoreWordVectorsForArticles a = new createZscoreWordVectorsForArticles();
        a.go();
    }
}
